#demo perl pointers.

#if you send two arrays to a subroutine, both arrays are stored in 
#the @_ as a single list. There is really no way to separate the two 
#arrays without knowing at least the size of the first one. However, 
#if you send two pointers to the subroutine, they can/will contain 
#the addresses of the original arrays and allow easy separation and 
#dereferencing of those arrays.

@list1 = (1..15);
@list2 = (16..30);

display1 (@list1, @list2);

print "-" x 35, "\n";

display2 (\@list1, \@list2);

sub display1
{
	print "@_\n";
}

sub display2
{
	my ($pArr1, $pArr2) = @_;
	print "First array:";
	foreach $value (@$pArr1)
	{
		print $value . " ";
	} 
	
	print "\nSecond array:";
	foreach $value (@$pArr2)
	{
		print $value . " ";
	} 
}